package com.atguigu.distributed.lock.juc;

import java.util.concurrent.*;

public class T1 {
    public static void main(String[] args) {
        ExecutorService threadPool = new ThreadPoolExecutor(2, 5, 100L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(3),
                Executors.defaultThreadFactory(), new ThreadPoolExecutor.DiscardPolicy());
        try {

            for (int i = 1; i <= 8; i++) {
                final int tmp = i;
                threadPool.execute(()->{
                    System.out.println(Thread.currentThread().getName()+"号窗口，"+"服务顾客"+tmp);
                    try {
                        TimeUnit.SECONDS.sleep(4);

                    }catch (Exception e){

                    }
                });
            }
                }catch (Exception e){
                    e.printStackTrace();
                }finally {
            threadPool.shutdown();

                }


    }
}
